﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:be="clr-namespace:Brjnk.GpxExplorer.Workspace.BitmapExport"
                    xmlns:commonWpf="clr-namespace:Brjnk.Common.WPF;assembly=Common"
                    xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
                    xmlns:my="clr-namespace:Brjnk.GpxExplorer.UI.Controls"
                    xmlns:workspace="clr-namespace:Brjnk.GpxExplorer.Workspace">

    <be:ContentLayoutToOrientationConverter x:Key="ContentLayoutToOrientationConverter" />

    <Style x:Key="ValueTitleStyle" TargetType="TextBlock">
        <Setter Property="FontSize" Value="{Binding TitleFontSize}" />
        <Setter Property="Foreground" Value="DarkGray" />
        <Setter Property="Margin" Value="0 0 0 0" />
    </Style>

    <DataTemplate x:Key="LabelItemTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <CheckBox IsChecked="{Binding IsVisible}" />
            <TextBlock Grid.Column="1" Text="{Binding DataObject.Source.Name}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="UserLabelItemTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding IsVisible}" />
            <TextBlock Grid.Column="1" Text="{Binding Text}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="CreatorTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <!--  Tato šablona ignoruje vlastnosti Style.BacgroundBrush, Style.BorderBrush, Style.BorderThickness  -->
        <Border commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                              Mode=OneWayToSource}"
                commonWpf:ActualSizeObserver.IsObserved="True"
                commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                             Mode=OneWayToSource}"
                Visibility="{Binding IsVisible,
                                     Converter={StaticResource BooleanToVisibilityConverter}}">

            <TextBlock Margin="{Binding ContentMargin}"
                       FontSize="{Binding Style.FontSize}"
                       FontWeight="Bold"
                       Foreground="{Binding Style.FontColor,
                                            Converter={StaticResource ColorToBrushConverter}}"
                       Text="Created by GPX Explorer"
                       Visibility="{Binding IsVisible,
                                            Converter={StaticResource BooleanToVisibilityConverter}}">
                <TextBlock.RenderTransform>
                    <RotateTransform x:Name="unimportantName1" Angle="{Binding Style.ContentRotation}" />
                </TextBlock.RenderTransform>
            </TextBlock>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="CompassTemplate">
        <!--  Tato šablona ignoruje vlastnosti Style.BacgroundBrush, Style.BorderBrush, Style.BorderThickness  -->
        <Border commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                              Mode=OneWayToSource}"
                commonWpf:ActualSizeObserver.IsObserved="True"
                commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                             Mode=OneWayToSource}"
                Visibility="{Binding IsVisible,
                                     Converter={StaticResource BooleanToVisibilityConverter}}">
            <Border>
                <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Polygon Fill="#FF5C5C5C"
                             Points="0,45 15,0 30,45"
                             RenderTransformOrigin="0.5,0.5"
                             StrokeThickness="0">
                        <Polygon.RenderTransform>
                            <RotateTransform Angle="{Binding Source={workspace:GetWorkspace}, Path=MapManager.Angle}" />
                        </Polygon.RenderTransform>
                    </Polygon>
                    <TextBlock HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               FontSize="13"
                               FontWeight="Normal"
                               Foreground="White">
                        N
                    </TextBlock>
                </Grid>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="UserLabelTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Border Background="{Binding Arrow}">
            <Border Margin="{Binding ContentMargin}"
                    commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                                  Mode=OneWayToSource}"
                    commonWpf:ActualSizeObserver.IsObserved="True"
                    commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                                 Mode=OneWayToSource}">
                <StackPanel Margin="{Binding ContentMarginInner}">
                    <StackPanel.LayoutTransform>
                        <RotateTransform x:Name="unimportantName1" Angle="{Binding Style.ContentRotation}" />
                    </StackPanel.LayoutTransform>
                    <Image MaxWidth="{Binding UserLabelStyle.ImageSize}"
                           MaxHeight="{Binding UserLabelStyle.ImageSize}"
                           Source="{Binding Image}">
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding UserLabelStyle.Layout}" Value="TextAndImage">
                                        <Setter Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                    <TextBlock MaxWidth="{Binding UserLabelStyle.MaxWidth}"
                               FontSize="{Binding Style.FontSize}"
                               Foreground="{Binding Style.FontColor,
                                                    Converter={StaticResource ColorToBrushConverter}}"
                               Text="{Binding Text}"
                               TextWrapping="Wrap" />
                    <Image MaxWidth="{Binding UserLabelStyle.ImageSize}"
                           MaxHeight="{Binding UserLabelStyle.ImageSize}"
                           Source="{Binding Image}">
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding UserLabelStyle.Layout}" Value="ImageAndText">
                                        <Setter Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </StackPanel>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="WaypointLabelTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Border Background="{Binding Arrow}"
                TextBlock.FontSize="{Binding Style.FontSize}"
                TextBlock.Foreground="{Binding Style.FontColor,
                                               Converter={StaticResource ColorToBrushConverter}}"
                Visibility="{Binding IsVisible,
                                     Converter={StaticResource BooleanToVisibilityConverter}}">
            <Border Margin="{Binding ContentMargin}"
                    commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                                  Mode=OneWayToSource}"
                    commonWpf:ActualSizeObserver.IsObserved="True"
                    commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                                 Mode=OneWayToSource}">
                <Border.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="Margin" Value="2" />
                    </Style>
                </Border.Resources>
                <StackPanel Margin="{Binding ContentMarginInner}" Orientation="{Binding WaypointLabelStyle.ContentLayout, Converter={StaticResource ContentLayoutToOrientationConverter}}">
                    <StackPanel.LayoutTransform>
                        <RotateTransform x:Name="unimportantName1" Angle="{Binding Style.ContentRotation}" />
                    </StackPanel.LayoutTransform>
                    <!--  Content  -->
                    <!--  Name  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowName, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptName}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1"
                                   FontWeight="Bold"
                                   Text="{Binding Waypoint.Source.Name}" />
                    </Grid>
                    <!--  Coordinates  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowWptCoordinates, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptCoordinates}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1"
                                   FontWeight="Bold"
                                   Text="{Binding Waypoint.Source.Position}" />
                    </Grid>
                    <!--  Comment  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowWptComment, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptComment}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Comment}" />
                    </Grid>
                    <!--  Description  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowWptDescription, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptDescription}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Description}" />
                    </Grid>
                    <!--  Time  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowWptTime, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptTime}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Time}" />
                    </Grid>
                    <!--  Elevation  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowWptElevation, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptElevation}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Elevation, Converter={StaticResource NullableConverter}}" />
                    </Grid>
                    <!--  Geocache.Name  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowGcName, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptGcName}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Geocache.Name}" />
                    </Grid>
                    <!--  Difficulty, Terrain, Size  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowGcDTSize, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptGcDTSize}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <TextBlock Text="{Binding Waypoint.Source.Geocache.Difficulty}" />
                            <TextBlock Text="{l:Loc wptGcDTSizeSeparator}" />
                            <TextBlock Text="{Binding Waypoint.Source.Geocache.Terrain}" />
                            <TextBlock Text="{l:Loc wptGcDTSizeSeparator}" />
                            <TextBlock Text="{Binding Waypoint.Source.Geocache.Size}" />
                        </StackPanel>
                    </Grid>
                    <!--  Hint  -->
                    <Grid Visibility="{Binding WaypointLabelStyle.ShowGcHint, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc wptGcHint}"
                                   Visibility="{Binding WaypointLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Waypoint.Source.Geocache.Hint}" />
                    </Grid>
                </StackPanel>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="RouteLabelTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Border Background="{Binding Arrow}"
                TextBlock.FontSize="{Binding Style.FontSize}"
                TextBlock.Foreground="{Binding Style.FontColor,
                                               Converter={StaticResource ColorToBrushConverter}}"
                Visibility="{Binding IsVisible,
                                     Converter={StaticResource BooleanToVisibilityConverter}}">
            <Border Margin="{Binding ContentMargin}"
                    commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                                  Mode=OneWayToSource}"
                    commonWpf:ActualSizeObserver.IsObserved="True"
                    commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                                 Mode=OneWayToSource}">
                <Border.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="Margin" Value="2" />
                    </Style>
                </Border.Resources>
                <StackPanel Margin="{Binding ContentMarginInner}" Orientation="{Binding RouteLabelStyle.ContentLayout, Converter={StaticResource ContentLayoutToOrientationConverter}}">
                    <StackPanel.LayoutTransform>
                        <RotateTransform x:Name="unimportantName1" Angle="{Binding Style.ContentRotation}" />
                    </StackPanel.LayoutTransform>
                    <!--  Content  -->
                    <!--  Name  -->
                    <Grid Visibility="{Binding RouteLabelStyle.ShowName, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.ColumnSpan="2"
                                   Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc rteName}"
                                   Visibility="{Binding RouteLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1"
                                   FontWeight="Bold"
                                   Text="{Binding Route.Source.Name}" />

                        <Border Grid.Row="1"
                                Grid.Column="1"
                                Width="10"
                                Height="10"
                                Background="{Binding Route.Color,
                                                     Converter={StaticResource ColorToBrushConverter}}" />
                    </Grid>
                    <!--  Length  -->
                    <Grid Visibility="{Binding RouteLabelStyle.ShowRteLength, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc rteLength}"
                                   Visibility="{Binding RouteLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1"
                                   FontWeight="Bold"
                                   Text="{Binding Route.Distance}" />
                    </Grid>
                </StackPanel>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="TrackLabelTemplate">
        <DataTemplate.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="0 0 0 0" />
            </Style>
        </DataTemplate.Resources>
        <Border Background="{Binding Arrow}"
                TextBlock.FontSize="{Binding Style.FontSize}"
                TextBlock.Foreground="{Binding Style.FontColor,
                                               Converter={StaticResource ColorToBrushConverter}}"
                Visibility="{Binding IsVisible,
                                     Converter={StaticResource BooleanToVisibilityConverter}}">
            <Border Margin="{Binding ContentMargin}"
                    commonWpf:ActualSizeObserver.Height="{Binding ContentHeight,
                                                                  Mode=OneWayToSource}"
                    commonWpf:ActualSizeObserver.IsObserved="True"
                    commonWpf:ActualSizeObserver.Width="{Binding ContentWidth,
                                                                 Mode=OneWayToSource}">
                <Border.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="Margin" Value="2" />
                    </Style>
                </Border.Resources>
                <StackPanel Margin="{Binding ContentMarginInner}" Orientation="{Binding TrackLabelStyle.ContentLayout, Converter={StaticResource ContentLayoutToOrientationConverter}}">
                    <StackPanel.LayoutTransform>
                        <RotateTransform x:Name="unimportantName1" Angle="{Binding Style.ContentRotation}" />
                    </StackPanel.LayoutTransform>

                    <!--  Content  -->
                    <!--  Name  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowName, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.ColumnSpan="2"
                                   Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkName}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1"
                                   FontWeight="Bold"
                                   Text="{Binding Track.Source.Name}" />
                        <Border Grid.Row="1"
                                Grid.Column="1"
                                Width="10"
                                Height="10"
                                Background="{Binding Track.Color,
                                                     Converter={StaticResource ColorToBrushConverter}}" />
                    </Grid>
                    <!--  Length  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowTrkLength, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkLength}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Track.DistanceJoined}" />
                    </Grid>
                    <!--  AvgSpeed  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowTrkAvgSpeed, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkAvgSpeed}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Track.AvgSpeedJoined}" />
                    </Grid>
                    <!--  Duration  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowTrkDuration, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkDuration}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Track.DurationJoined}" />
                    </Grid>
                    <!--  Rised  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowTrkRised, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkRised}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Track.RisedJoined}" />
                    </Grid>
                    <!--  Fallen  -->
                    <Grid Visibility="{Binding TrackLabelStyle.ShowTrkFallen, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Style="{StaticResource ValueTitleStyle}"
                                   Text="{l:Loc trkFallen}"
                                   Visibility="{Binding TrackLabelStyle.ShowValueTitles,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <TextBlock Grid.Row="1" Text="{Binding Track.FallenJoined}" />
                    </Grid>
                </StackPanel>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="UserLabelEditTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <!--  Obsah  -->
            <TextBlock Grid.Row="0" Text="{l:Loc bitmapExportLabelText}" />
            <TextBox Grid.Row="0"
                     Grid.Column="1"
                     Text="{Binding Text,
                                    UpdateSourceTrigger=PropertyChanged}" />
            <CheckBox Name="chbxMaxWidth"
                      Grid.Row="1"
                      Content="{l:Loc bitmapExportMaxWidth}"
                      IsChecked="{Binding UserLabelStyle.IsMaxWidthLocal}" />
            <Slider Grid.Row="1"
                    Grid.Column="1"
                    IsEnabled="{Binding Path=IsChecked,
                                        ElementName=chbxMaxWidth}"
                    Maximum="1000"
                    Minimum="1"
                    Value="{Binding UserLabelStyle.MaxWidth}" />
            <TextBlock Grid.Row="3" Text="{l:Loc bitmapExportLabelLayout}" />
            <my:EnumPicker Grid.Row="3"
                           Grid.Column="1"
                           EnumType="{x:Type be:UserLabelLayout}"
                           Value="{Binding UserLabelStyle.Layout}" />
            <TextBlock Grid.Row="4" Text="{l:Loc bitmapExportImageSize}" />
            <Slider Grid.Row="4"
                    Grid.Column="1"
                    Maximum="1000"
                    Minimum="0"
                    Value="{Binding UserLabelStyle.ImageSize}" />

            <!--  Obrázek  -->
            <StackPanel Grid.Row="5"
                        Grid.ColumnSpan="2"
                        Orientation="Horizontal">
                <Button Command="{Binding Path=RemoveImageCommand}"
                        CommandParameter="{Binding}"
                        Content="{l:Loc bitmapExportRemoveImage}" />
                <Button Command="{Binding Path=ChooseImageCommand}"
                        CommandParameter="{Binding}"
                        Content="{l:Loc bitmapExportChooseImage}" />
            </StackPanel>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="WaypointLabelEditTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <CheckBox Name="chbxShowName"
                      Grid.Row="0"
                      Content="{l:Loc bitmapExportWaypointShowName}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowNameLocal}" />
            <ComboBox Grid.Row="0"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowName,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowName,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowWptCoordinates"
                      Grid.Row="1"
                      Content="{l:Loc bitmapExportWaypointShowWptCoordinates}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowWptCoordinatesLocal}" />
            <ComboBox Grid.Row="1"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowWptCoordinates,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowWptCoordinates,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowWptComment"
                      Grid.Row="2"
                      Content="{l:Loc bitmapExportWaypointShowWptComment}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowWptCommentLocal}" />
            <ComboBox Grid.Row="2"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowWptComment,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowWptComment,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowWptDescription"
                      Grid.Row="3"
                      Content="{l:Loc bitmapExportWaypointShowWptDescription}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowWptDescriptionLocal}" />
            <ComboBox Grid.Row="3"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowWptDescription,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowWptDescription,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowWptElevation"
                      Grid.Row="4"
                      Content="{l:Loc bitmapExportWaypointShowWptElevation}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowWptElevationLocal}" />
            <ComboBox Grid.Row="4"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowWptElevation,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowWptElevation,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowWptTime"
                      Grid.Row="5"
                      Content="{l:Loc bitmapExportWaypointShowWptTime}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowWptTimeLocal}" />
            <ComboBox Grid.Row="5"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowWptTime,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowWptTime,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowGcName"
                      Grid.Row="6"
                      Content="{l:Loc bitmapExportWaypointShowGcName}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowGcNameLocal}" />
            <ComboBox Grid.Row="6"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowGcName,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowGcName,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowGcDTSize"
                      Grid.Row="7"
                      Content="{l:Loc bitmapExportWaypointShowGCDTSize}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowGcDTSizeLocal}" />
            <ComboBox Grid.Row="7"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowGcDTSize,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowGcDTSize,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowHint"
                      Grid.Row="8"
                      Content="{l:Loc bitmapExportWaypointShowHint}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowGcHintLocal}" />
            <ComboBox Grid.Row="8"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowHint,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowGcHint,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowValueTitles"
                      Grid.Row="9"
                      Content="{l:Loc bitmapExportWaypointShowTitles}"
                      IsChecked="{Binding WaypointLabelStyle.IsShowValueTitlesLocal}" />
            <ComboBox Grid.Row="9"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowValueTitles,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=WaypointLabelStyle.ShowValueTitles,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxContentLayout"
                      Grid.Row="10"
                      Content="{l:Loc bitmapExportWaypointContentLayout}"
                      IsChecked="{Binding WaypointLabelStyle.IsContentLayoutLocal}" />
            <my:EnumPicker Grid.Row="10"
                           Grid.Column="1"
                           EnumType="{x:Type be:ContentLayout}"
                           IsEnabled="{Binding ElementName=chbxContentLayout,
                                               Path=IsChecked}"
                           Value="{Binding WaypointLabelStyle.ContentLayout}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="RouteLabelEditTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <CheckBox Name="chbxShowName"
                      Grid.Row="0"
                      Content="{l:Loc bitmapExportRouteShowName}"
                      IsChecked="{Binding RouteLabelStyle.IsShowNameLocal}" />
            <ComboBox Grid.Row="0"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowName,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=RouteLabelStyle.ShowName,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowRteLength"
                      Grid.Row="1"
                      Content="{l:Loc bitmapExportRouteShowRteLength}"
                      IsChecked="{Binding RouteLabelStyle.IsShowRteLengthLocal}" />
            <ComboBox Grid.Row="1"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowRteLength,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=RouteLabelStyle.ShowRteLength,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowValueTitles"
                      Grid.Row="2"
                      Content="{l:Loc bitmapExportRouteShowValue}"
                      IsChecked="{Binding RouteLabelStyle.IsShowValueTitlesLocal}" />
            <ComboBox Grid.Row="2"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowValueTitles,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=RouteLabelStyle.ShowValueTitles,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxContentLayout"
                      Grid.Row="3"
                      Content="{l:Loc bitmapExportRouteLayout}"
                      IsChecked="{Binding RouteLabelStyle.IsContentLayoutLocal}" />
            <my:EnumPicker Grid.Row="3"
                           Grid.Column="1"
                           EnumType="{x:Type be:ContentLayout}"
                           IsEnabled="{Binding ElementName=chbxContentLayout,
                                               Path=IsChecked}"
                           Value="{Binding RouteLabelStyle.ContentLayout}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="TrackLabelEditTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <CheckBox Name="chbxShowName"
                      Grid.Row="0"
                      Content="{l:Loc bitmapExportTrackShowName}"
                      IsChecked="{Binding TrackLabelStyle.IsShowNameLocal}" />
            <ComboBox Grid.Row="0"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowName,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowName,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowTrkLength"
                      Grid.Row="1"
                      Content="{l:Loc bitmapExportTrackShowTrkLength}"
                      IsChecked="{Binding TrackLabelStyle.IsShowTrkLengthLocal}" />
            <ComboBox Grid.Row="1"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowTrkLength,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowTrkLength,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowTrkAvgSpeed"
                      Grid.Row="2"
                      Content="{l:Loc bitmapExportTrackShowTrkAvgSpeed}"
                      IsChecked="{Binding TrackLabelStyle.IsShowTrkAvgSpeedLocal}" />
            <ComboBox Grid.Row="2"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowTrkAvgSpeed,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowTrkAvgSpeed,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowTrkDuration"
                      Grid.Row="3"
                      Content="{l:Loc bitmapExportTrackShowTrkDuration}"
                      IsChecked="{Binding TrackLabelStyle.IsShowTrkDurationLocal}" />
            <ComboBox Grid.Row="3"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowTrkDuration,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowTrkDuration,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowTrkRised"
                      Grid.Row="4"
                      Content="{l:Loc bitmapExportTrackShowTrkRised}"
                      IsChecked="{Binding TrackLabelStyle.IsShowTrkRisedLocal}" />
            <ComboBox Grid.Row="4"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowTrkRised,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowTrkRised,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowTrkFallen"
                      Grid.Row="5"
                      Content="{l:Loc bitmapExportTrackShowTrkFallen}"
                      IsChecked="{Binding TrackLabelStyle.IsShowTrkFallenLocal}" />
            <ComboBox Grid.Row="5"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowTrkFallen,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowTrkFallen,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxShowValueTitles"
                      Grid.Row="6"
                      Content="{l:Loc bitmapExportTrackShowTitles}"
                      IsChecked="{Binding TrackLabelStyle.IsShowValueTitlesLocal}" />
            <ComboBox Grid.Row="6"
                      Grid.Column="1"
                      IsEnabled="{Binding ElementName=chbxShowValueTitles,
                                          Path=IsChecked}"
                      SelectedIndex="{Binding Path=TrackLabelStyle.ShowValueTitles,
                                              Converter={StaticResource BoolToIntConverter}}">
                <ComboBoxItem Content="{l:Loc bitmapExportHide}" />
                <ComboBoxItem Content="{l:Loc bitmapExportShow}" />
            </ComboBox>

            <CheckBox Name="chbxContentLayout"
                      Grid.Row="7"
                      Content="{l:Loc bitmapExportTrackLayout}"
                      IsChecked="{Binding TrackLabelStyle.IsContentLayoutLocal}" />
            <my:EnumPicker Grid.Row="7"
                           Grid.Column="1"
                           EnumType="{x:Type be:ContentLayout}"
                           IsEnabled="{Binding ElementName=chbxContentLayout,
                                               Path=IsChecked}"
                           Value="{Binding TrackLabelStyle.ContentLayout}" />
        </Grid>
    </DataTemplate>
</ResourceDictionary>